package com.excel.write;

import com.excel.entity.CCell;

import java.util.LinkedList;
import java.util.List;

public class ExcelContent {
    private CHead cHead;

    private List<CRow> cRow;

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public CHead getcHead() {
        return cHead;
    }

    public void setcHead(CHead cHead) {
        this.cHead = cHead;
    }

    public List<CRow> getcRow() {
        return cRow;
    }

    public void setcRow(List<CRow> cRow) {
        this.cRow = cRow;
    }

    public List<CCell> getHeaders() {
        return getcHead().getHeaders();
    }


    public static final class ExcelContentBuilder {
        private CHead cHead = new CHead();
        private List<CRow> cRow = new LinkedList<>();
        private String name;

        private ExcelContentBuilder() {
            cRow = new LinkedList<>();
        }

        public static ExcelContentBuilder anExcelContent() {
            return new ExcelContentBuilder();
        }

        public ExcelContentBuilder withCHead(CHead cHead) {
            this.cHead = cHead;
            return this;
        }

        public ExcelContentBuilder withCRow(CRow cRow) {
            this.cRow.add(cRow);
            return this;
        }

        public ExcelContentBuilder withName(String name) {
            this.name = name;
            return this;
        }

        public ExcelContent build() {
            ExcelContent excelContent = new ExcelContent();
            excelContent.setName(name);
            excelContent.cRow = this.cRow;
            excelContent.cHead = this.cHead;
            return excelContent;
        }
    }
}
